Feature/fix toggle comment indent #25782
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #25780
The PR has 2 commits for 2 steps: refactor and fix.
Refactor step slightly changes the behaviour of toggle_comment in the Shader Editor, updating the caret position but by the wrong offset (hardcoded 1 instead of 2 since comment delimiter is "//").
Fix replaces the hardcoded 1 with delimiter length to make solution generic.
After discussion with @Paulb23, I decided to extract the toggle_inline_comment method in
CodeTextEditor
(child ofScriptTextEditor
, and also the base class forShaderTextEditor
) rather thanTextEdit
(the actual part where you read and edit text). Technically it could be part ofTextEdit
, but the current convention seems to move higher-level text manipulation to theCodeTextEditor
. On my next PR (for #22177), I will probably have a pass on the comment-related methods still in TextEdit.